//
//  WarningView.m
//  AffectionBee
//
//  Created by 李通 on 16/8/21.
//  Copyright © 2016年 chivalrous. All rights reserved.
//

#import "WarningView.h"

@interface WarningView ()

@property (nonatomic,weak) UILabel *noticeLabel;

@end

@implementation WarningView

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        
        [self setContentControl];
        self.layer.cornerRadius = 20;
        self.backgroundColor = kHomeBGColor;
    }
    return self;
}

- (void)setContentControl {
    
    UIImageView *imageView = [[UIImageView alloc]init];
    imageView.image = [UIImage imageNamed:@"v2_orderSuccess"];
    [self addSubview:imageView];
    
    UILabel *noticeLabel = [[UILabel alloc]init];
    self.noticeLabel = noticeLabel;
    noticeLabel.numberOfLines = 0;
    [self addSubview:noticeLabel];
    
    UILabel *label = [[UILabel alloc]init];
    label.text = @"今天先买这么多，明天再来看看吧~";
    label.numberOfLines = 0;
    [self addSubview:label];
    
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.top.equalTo(self).offset(5);
        make.width.height.equalTo(@80);
    }];
    [noticeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(imageView.mas_bottom).offset(5);
        make.leading.equalTo(self).offset(10);
        make.width.equalTo(@(self.frame.size.width - 20));
    }];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.equalTo(_noticeLabel);
        make.top.equalTo(_noticeLabel.mas_bottom);
    }];
}

- (void)warningWithTitle:(NSString *)title {
    
    self.noticeLabel.text = [NSString stringWithFormat:@"%@ 库存不足了",title];
}

@end
